﻿using System.Collections.Generic;
using System.Linq;

namespace NiuX;

public static class CollectionExtensions
{
    /// <summary>
    /// 是否子集
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="source"></param>
    /// <param name="other"></param>
    /// <returns></returns>
    public static bool IsSubSetOf<T>(this IEnumerable<T> source, IEnumerable<T> other)
    {
        // 两种方式，未测试性能
        //return other.Except(source).Any();
        return source.All(other.Contains);
    }
}